<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="/public/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" href="/public/static/h-ui/css/H-ui.admin.css"/>
</head>
<body>
<div class="Hui-article">
    <article class="cl pd-20">
        <form action="" method="post" class="form form-horizontal" id="form-admin-role-add">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">设置权限：</label>
                <select style="height: 32px;  width: 63%;" class="select" size="1" id="role_id">
                    {volist name="role_list" id="r"}
                    <option value="{$r.role_id}" {if $permission['role_id'] == $r['role_id']}selected{/if}>{$r.role_name}</option>
                    {/volist}
                </select>
            </div>
            {if $permission!=-1}
            <div class="row cl" >
                <label class="form-label col-xs-4 col-sm-3">是否显示版权信息：</label>
                <select style="height: 32px;  width: 63%;" class="select" size="1" id="is_show_copyright">
                    <option value="0" {if $permission['is_show_copyright'] == 0}selected{/if}>显示</option>
                    <option value="1" {if $permission['is_show_copyright'] == 1}selected{/if}>不显示</option>
                </select>
            </div>
            {/if}
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3" style="padding-left: 0;">
                    <button type="button" onclick="add_RoleManage()" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
                </div>
            </div>
        </form>
    </article>
</div>
<input type="hidden" value="{$uid}" id="uid">
<script src="/public/js/jquery-2.1.1.js"></script>
<script src="/public/static/layer/2.4/layer.js"></script>
<script type="text/javascript">
    var lock = false;
    //添加
    function add_RoleManage() {
        var role_id=$("#role_id").val();
        var is_show_copyright=$("#is_show_copyright").val();
        var uid=$("#uid").val();
        if(!lock){
            lock = true;
            $.ajax({
                url : "{:url('role/permission_edit_do')}",
                type : "post",
                data : {
                    "role_id" : role_id,
                    "uid" : uid,
                    'is_show_copyright':is_show_copyright
                },
                success : function(res) {
                    if(res['code']>0){
                        layer.msg('添加成功!',{icon:1,time:1000},function () {
                            window.parent.location.reload();
                        });
                    }
                    else{
                        layer.msg('添加失败！',{icon:5,time:1000});
                        lock = false;
                    }
                }
            })
        }
    }
</script>
</body>
</html>